package com.xtianzhuang.www.exception;

import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xtianzhuang.www.entity.response.base.BaseResponse;

@ControllerAdvice
public class MybatisException {
	@ResponseBody
	@ExceptionHandler(SQLException.class)
	public BaseResponse handleSqlException(HttpServletRequest request, HttpServletResponse httpServletResponse,
			Exception ex) {
		BaseResponse response = new BaseResponse();
		response.setCode("6000");
		response.setMessage("数据库操作失败：" + ex.getMessage());
		return response;
	}
	

}
